<template>
  <div class="details">
    <div class="bg"></div>
    <div class="container">
      <span class="title">产品详情</span>
      <div class="hr"></div>
      <div class="detail">
        <div
          v-if="res"
          class="data"
        >
          <div class="dimg">
            <img
              :src="res.img"
              alt=""
            />
          </div>
          <div class="dinfo">
            <p class="dtitle">{{ res.title }}</p>
            <p class="dprice">
              <span>价格：</span><span class="d_p">￥{{ res.price }}</span><span class="del">￥ {{res.oldPrice}}</span>
            </p>
            <p class="hr"></p>
            <p class="dprice">评论：0条 <span class="sx"></span>收藏：0</p>
            <p class="hr"></p>
            <p>产品类型: <span
                @click="isChicks"
                :class="(isChick?'':'isc')+' lx'"
              >标配</span></p>
            <div class="flex">
              <span class="mr20">购买数量:</span>
              <!-- <input
                type="text"
                class="input"
                value="1"
              />
              <span class="arrow">
                <span class="up_arrow">
                  <span></span>
                </span>
                <span class="down_arrow">
                  <span></span>
                </span>
              </span> -->
              <van-stepper
                v-model="value"
                integer
              />
              <span class="kc">库存量:</span>
              <span class="dkc">100</span>
            </div>
            <div class="anz">
              <div
                class="a_btn a1"
                @click="isgo"
              >
                <img
                  src="../assets/icon/gwc.png"
                  alt=""
                  width="30px"
                />
                <span>加入购物车</span>
              </div>
              <div
                class="a_btn a2"
                @click="isgo"
              >
                立即购买
              </div>
            </div>
            <p class="cpbz">
              产品保证
              <img
                src="../assets/icon/dui.png"
                alt=""
                width="24px"
              />
              正品保证
              <img
                src="../assets/icon/dui.png"
                alt=""
                width="24px"
              />
              快速发货
            </p>
          </div>
        </div>
        <div class="hover">
          <div
            @click="isgo"
            class="sc"
          >收藏</div>
          <div
            @click="isgo"
            class="fx"
          >分享</div>
          <div
            @click="isgo"
            class="kf"
          >在线客服</div>
        </div>
        <ul class="childnav">
          <li
            @click="choose(0)"
            :class="{ active: isShow == 0 }"
          >产品详情</li>
          |
          <li
            @click="choose(1)"
            :class="{ active: isShow == 1 }"
          >
            销售记录(0)
          </li>
          |
          <li
            @click="choose(2)"
            :class="{ active: isShow == 2 }"
          >
            产品评论(0)
          </li>
        </ul>
        <div
          class="shop-detail"
          v-show="isShow == 0"
        >
          <div style="width:100%">
            <img
              style="width:100%"
              :src="res.detail"
            >
          </div>
        </div>
        <div
          class="jilu"
          v-show="isShow == 1"
        >
          <table>
            <tr class="one">
              <td>买家</td>
              <td>选项​​信息</td>
              <td>数量</td>
              <td>成交时间</td>
            </tr>
          </table>
        </div>
        <div
          class="form"
          v-show="isShow == 2"
        >
          <p>您没有登录,不能提交,请先<span
              class="blue"
              style="cursor: pointer;"
              @click="isgo"
            >登录</span></p>
          <!-- <div class="main">
            <div>
              <span class="left">产品评星：</span>
              <span
                class="xx"
                :class="{ xx_1: xj >= 1 }"
              ></span>
              <span
                class="xx"
                :class="{ xx_1: xj >= 2 }"
              ></span>
              <span
                class="xx"
                :class="{ xx_1: xj >= 3 }"
              ></span>
              <span
                class="xx"
                :class="{ xx_1: xj >= 4 }"
              ></span>
              <span
                class="xx"
                :class="{ xx_1: xj >= 5 }"
              ></span>
            </div>
            <div>
              <span class="left">昵称：</span>
              <input type="text" />
            </div>
            <div>
              <span class="left">评论內容：</span>
              <textarea
                type="text"
                placeholder="暂无评论,快来发表吧"
              />
            </div>
            <div>
              <span class="left">验证码：</span>
              <input type="text" />
              <img
                class="m-l-8"
                src="https://icpedi.yswebportal.cc/validateCode.jsp?736.3908193733166"
                alt=""
              />
            </div>
            <div>
              <span class="left">上传图片：</span>
              <input
                type="button"
                value="+"
                class="zfx"
              />
              <span class="m-l-8">(可上传 5
                张图片,每张不超过5M，支持格式jpg，jpeg，bmp，png，gif）</span>
            </div>
            <div class="btntj">提交评论</div>
          </div> -->
        </div>

      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      value: 0,
      res: null,
      isShow: 0,
      xj: 3,
      isChick: true
    };
  },
  watch: {
    $route () {
      this.axios.get("json/headerfl.json").then((res) => {
        this.res =
          res.data.res[this.$route.query.index].details[this.$route.query.i];
      });
    },
  },
  mounted () {
    this.axios.get("json/headerfl.json").then((res) => {
      this.res =
        res.data.res[this.$route.query.index].details[this.$route.query.i];
    });

  },
  methods: {
    choose (i) {
      this.isShow = i;
    },
    isgo () {
      this.$router.push('/login');
    },
    isChicks () {
      this.isChick = !this.isChick
    }
  },
};
</script>
<style scoped>
.flex {
  display: flex;
  align-items: center;
}
.mr20 {
  margin-right: 20px;
}
.isc {
  border-color: #ff6637 !important;
}
</style>
<style lang="scss" scoped>
$fc: #ff6637;
.details {
  .container {
    margin-bottom: 16px;
  }
  .bg {
    width: 100%;
    height: 450px;
    background: url("../assets/swiper/1.png") no-repeat;
    background-position-x: center;
  }
  .title {
    margin-top: 16px;
    display: inline-block;
    padding: 12px 20px;
    color: $fc;
    font-size: 16px;
  }
  .hr {
    height: 1px;
    background-color: #eaeaea;
  }
  .detail {
    padding: 0 16px;
  }
  .data {
    padding: 32px 0 0 0;
    display: flex;
    color: #666;
    font-size: 14px;
    .dimg {
      border: 1px solid #eaeaea;
      flex: 0 0 40%;
      img {
        width: 100%;
      }
    }
    .dinfo {
      margin-left: 64px;
      flex: 0 0 50%;
      .dtitle {
        font-size: 20px;
        color: #585858;
      }
      .dprice {
        padding: 32px;
        display: flex;
        align-items: center;

        .d_p {
          font-size: 40px;
          font-weight: 700;
          color: $fc;
        }
        .del {
          padding-left: 6px;
          text-decoration: line-through;
        }
        .sx {
          display: inline-block;
          width: 1px;
          height: 24px;
          background-color: #eaeaea;
          margin: 0 60px;
        }
      }
      .lx {
        box-sizing: border-box;
        display: inline-block;
        margin: 16px;
        border: 1px solid #eaeaea;
        border-radius: 20px;
        cursor: pointer;
        padding: 8px 12px;
        &:hover {
          border: 1px solid $fc;
        }
      }
      .input {
        text-align: center;
        margin: 0 6px 0 24px;
        box-sizing: border-box;
        border: 1px solid #eaeaea;
        border-radius: 3px;
        width: 55px;
        height: 40px;
        &:focus {
          border: 2px solid #000;
        }
      }
      .arrow {
        position: relative;
        display: inline-block;
        width: 20px;
        height: 40px;
        .up_arrow {
          box-sizing: border-box;
          display: inline-block;
          width: 16px;
          height: 16px;
          top: 16px;
          left: 0;
          position: absolute;
          border: 1px solid #e8e8e8;
          span {
            position: absolute;
            top: -2px;
            left: 1px;
            border: 6px solid transparent;
            border-bottom: 6px solid #000;
          }
        }
        .down_arrow {
          box-sizing: border-box;
          display: inline-block;
          width: 16px;
          height: 16px;
          top: 36px;
          left: 0;
          position: absolute;
          border: 1px solid #e8e8e8;
          span {
            position: absolute;
            top: 4px;
            left: 1px;
            border: 6px solid transparent;
            border-top: 6px solid #000;
          }
        }
      }
      .kc {
        margin-left: 10px;
      }
      .dkc {
        margin-left: 10px;
      }
      .anz {
        padding: 36px 0;
        display: flex;
        .a_btn {
          display: flex;
          justify-content: center;
          align-items: center;
          text-align: center;
          width: 160px;
          font-size: 16px;
          padding: 8px 16px;
          border: 1px solid $fc;
          border-radius: 3px;
        }
        .a1 {
          cursor: pointer;
          margin-right: 50px;
          color: $fc;
          span {
            margin-left: 16px;
          }
        }
        .a2 {
          cursor: pointer;
          background-color: $fc;
          color: #fff;
        }
      }
      .cpbz {
        display: flex;
        align-items: center;
        img {
          margin: 0 4px 0 24px;
        }
      }
    }
  }
  .hover {
    color: rgb(102, 102, 102);
    font-size: 14px;
    display: flex;
    padding: 32px 12px;
    div {
      height: 24px;
      line-height: 24px;
      background-repeat: no-repeat;
      background-size: 24px;
      padding: 0 0 0 30px;
      & + div {
        margin-left: 32px;
      }
    }
    .sc {
      background-image: url("../assets/icon/sc_0.png");
      cursor: pointer;
      &:hover {
        color: $fc;
        background-image: url("../assets/icon/sc_1.png");
      }
    }
    .fx {
      cursor: pointer;
      background-image: url("../assets/icon/fx_0.png");
      &:hover {
        color: $fc;
        background-image: url("../assets/icon/fx_1.png");
      }
    }
    .kf {
      cursor: pointer;
      background-image: url("../assets/icon/kf_0.png");
      &:hover {
        color: $fc;
        background-image: url("../assets/icon/kf_1.png");
      }
    }
  }
  .childnav {
    color: #e8e8e8;
    font-size: 14px;
    margin: 32px 12px;
    display: flex;
    border: 1px solid #e8e8e8;
    align-items: center;
    li {
      position: relative;
      padding: 20px 48px;
      color: rgb(102, 102, 102);
      cursor: pointer;
    }
    li:last-child {
      border-right: 1px solid #e8e8e8;
    }
    .active {
      border-top: 4px solid $fc;
      color: $fc;
    }
  }
  .form {
    padding: 0 12px;
    p {
      margin-bottom: 70px;
      text-align: center;
      font-size: 14px;
      color: #ff0000;
      .blue {
        color: blue;
      }
    }
    .main {
      background-color: #f8f8f8;
      padding-bottom: 16px;
      padding-top: 32px;
      div {
        display: flex;
        align-items: center;
        padding: 16px 0;
        textarea {
          box-sizing: border-box;
          padding: 2px;
          width: 800px;
          height: 100px;
          border: 1px solid #e8e8e8;
          resize: none;
          &:focus {
            border: 2px solid #000;
            padding: 1px;
          }
        }
        input {
          width: 150px;
          height: 50px;
          border-radius: 3px;
          border: 1px solid #e8e8e8;
          box-sizing: border-box;
          &:focus {
            border: 2px solid #000;
          }
        }
        img {
          width: 80px;
        }
        .m-l-8 {
          margin-left: 8px;
          font-size: 12px;
          color: #aeaeae;
        }
        .zfx {
          width: 50px;
          background-color: transparent;
          font-size: 42px;
          font-weight: 100;
          color: #666666;
          &:focus {
            border: 1px solid #e8e8e8;
          }
        }
        .left {
          margin-right: 8px;
          font-size: 14px;
          color: #666666;
          text-align: end;
          width: 120px;
          display: inline-block;
        }
        .xx {
          width: 20px;
          height: 20px;
          background-repeat: no-repeat;
          background-size: 20px;
          background-image: url("../assets/icon/xx_0.png");
          &.xx_1 {
            background-image: url("../assets/icon/xx_1.png");
          }
        }
      }
      .btntj {
        margin: 16px auto;
        display: block;
        border-radius: 5px;
        text-align: center;
        width: 200px;
        background-color: $fc;
        color: #fff;
      }
    }
  }
  .jilu {
    padding: 32px 12px;
    table {
      width: 100%;
      tr {
        height: 43px;
      }
      td {
        vertical-align: middle;
        text-align: center;
      }
      .one {
        background-color: #f3f3f3;
      }
    }
  }
  .info {
    padding: 32px 12px;
    display: flex;
    div {
      flex: 0 0 50%;
      display: flex;
      .iname {
        background-color: #f8f8f8;
        padding: 16px 24px 16px 60px;
        border: 1px solid #e8e8e8;
      }
      .inn {
        flex-grow: 1;
        border: 1px solid #e8e8e8;
        border-left: 0;
        padding: 16px 0 16px 24px;
      }
      &:nth-child(2n + 1) {
        .inn {
          border-right: 0;
        }
      }
    }
  }
}
</style>
